<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>查看成绩</title>
    <link rel="stylesheet" th:href="@{/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css}"/>
    <script th:src="@{/js/jquery-3.2.1.min.js}"></script>
</head>
<body>
<div class="container-fluid">
    <ol class="breadcrumb nav-top">
        <li><a th:href="@{~/router/index.html}" >首页</a></li>
        <li class="active">查看成绩</li>
    </ol>

    <!--<button id="sq" class="btn btn-primary">请假</button>-->
    <div>
        <select name="xq" id="semester">
            <option>==选择学期==</option>
            <option value="第一学期">第一学期</option>
            <option value="第二学期">第二学期</option>
        </select>
        <select name="xn" id="year">
            <option readonly>==选择学年==</option>
            <option value="2016-2017">2016-2017</option>
            <option value="2017-2018">2017-2018</option>
            <option value="2018-2019">2018-2019</option>
            <option value="2019-2020">2019-2020</option>
            <option value="2020-2021">2020-2021</option>
            <option value="2021-2022">2021-2022</option>
        </select>
        <button id="select">检索</button>
    </div>
    <table class="table table-striped tb">
        <thead>
        <tr class="text-center">
            <td>科目</td>
            <td>考试分数</td>
            <td>考勤分数</td>
            <td>总数</td>
            <td>备注</td>
        </tr>
        </thead>
        <tbody id="dataTable">

        </tbody>
    </table>
    <script>
        $(function(){
            $("#select").click(function(){
                $("#dataTable").empty();
                var semester = $("#semester").val();
                var year = $("#year").val();
                $.ajax({
                    url:"/score/studentLookScore",
                    data:{"semester":semester,"year":year},
                    success:function(data){
                        console.log(data)
                        for(var i=0;i<data.length;i++){
                            console.log(data[i].courseName);
                            var total = data[i].score*0.85+data[i].work*0.15;
                            var tr= "<tr class='text-center'>\n" +
                                        "<td>"+data[i].courseName+"</td>\n" +
                                        "<td>"+data[i].score+"</td>\n" +
                                        "<td>"+data[i].work+"</td>\n" +
                                        "<td>"+total.toFixed(2)+"</td>\n" +
                                        "<td></td>\n" +
                                    "</tr>";
                            $("#dataTable").append(tr);
                        }
                    }
                })
            })
        })
    </script>

</div>
</body>
</html>